#!/usr/bin/env python3  /*设定脚本文件直接能执行*/
# -*- coding:utf-8 -*-   /*设置编码*/
"""
@Author: WANDERSON M.PIMENTA
@Software: PyCharm 、Qt Designer and PySide6
@File: tQPushButton.py
@Time: 2024/05/11 16:35
@Function：ctQPushButton：自定义的按键控件
"""
from tQQtCore import *

# style样式
style = '''
QPushButton {{
	border: none;
    padding-left: 10px;
    padding-right: 5px;
    color: {_color};
	border-radius: {_radius};	
	background-color: {_bg_color};
}}
QPushButton:hover {{
	background-color: {_bg_color_hover};
}}
QPushButton:pressed {{	
	background-color: {_bg_color_pressed};
}}
'''


class ctQPushButton(QPushButton):
    """
    自定义的按键控件
    """

    def __init__(self,
                 text,
                 radius,
                 color,
                 bg_color,
                 bg_color_hover,
                 bg_color_pressed,
                 parent=None):
        super().__init__()
        # 按键设置参数
        self.setText(text)
        if parent is not None:
            self.setParent(parent)
        self.setCursor(Qt.PointingHandCursor)

        # 设置样式表
        custom_style = style.format(
            _color=color,
            _radius=radius,
            _bg_color=bg_color,
            _bg_color_hover=bg_color_hover,
            _bg_color_pressed=bg_color_pressed
        )
        self.setStyleSheet(custom_style)
